package com.demo.my.Controller;

import com.demo.my.Entity.Position;
import com.demo.my.Service.PositionService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/preAddPosition")
public class PreAddPositionServlet extends HttpServlet {
    private PositionService positionService=new PositionService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            int maxNumber=positionService.getMaxNumber();
            List<Position> list = positionService.getPositionList();
            req.setAttribute("list",list);
            req.setAttribute("positionNumber",maxNumber+1);
            req.getRequestDispatcher("/jsp/admin/position_add.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
